function Features = produceFeatures(dbname, network, bImResize, bSave)

%% user define
if nargin == 0
    bImResize = false;
    % bImResize = true;
    
    % network = 'DeepID';
    % network = 'VGG';
    network = 'LCNN';
    % network = 'LightenedCNN';
    
    dbname = 'LFW';
    
    % dbname = 'LFW6';
    % dbname = 'LFW6-cropped';
    % dbname = 'LFW6-cropped-gray';
    
    % dbname = 'AR';
end

[hFeature, N, ImgMean, scale, layer] = mycaffe.parseDeepFeatures(network, bImResize, dbname);

%%
ImgIndex = 1 : N;
fprintf('Creating %d %s features ...\n', length(ImgIndex), network);
Features = hFeature(ImgIndex);
fprintf('Done!\n');

if ~bSave
    return
end

%%
fprintf('Saving %s features ...\n', network);
sSuffix = '';
if ~isempty(ImgMean)
    sSuffix = '-UseMean';
end
if bImResize
    sSuffix = [sSuffix '-ImResize'];
end

MatFileName = sprintf('%s-{Scale=%d}-{Layer=%s}%s.mat', network, scale, layer.feature, sSuffix);

saveall(fullfile(mycaffe.path, dbname, MatFileName), Features);
fprintf('Done!\n');
